﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections;

namespace LUStationery.DAO
{
    public class PositionDAO
    {
        SqlConnection cn;
        SqlCommand cmd;
        public PositionDAO() 
        {
            cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        }

        public IDataReader getPosition()
        {
            
            cmd = new SqlCommand("Select * from position", cn);
            cn.Open();
            IDataReader idr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            return idr;
        }
        public IDataReader getPositionByDepartment(string deptCode)
        {
            cmd = new SqlCommand("Select position from users where department_code=@deptCode group by position", cn);
            cmd.Parameters.Add("@deptCode", SqlDbType.VarChar).Value = deptCode;
            cn.Open();
            IDataReader idr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            return idr;
        }
    }
}
